package D240425;

public class Fibonacci {
    private static int first;
    private static int second;

    public Fibonacci(int a, int b) {
        first = a;
        second = b;
    }

    public void add(int a) {
        if (a == 1) {
            System.out.println(first);
        } else if (a == 2) {
            System.out.println(second);
        } else {
            for (int i = 0; i < a - 2; i++) {
                int temp = first;
                first = second;
                second = temp + second;
            }
            System.out.println(second);
        }
    }

    public int addRecursion(int c) {
        int result;
        if (c == 1) {
            return first;
        } else if (c == 2) {
            return second;
        } else {
            result = addRecursion(c - 2) + addRecursion(c - 1);
        }
        return result;
    }
}
